﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using UtilZ.Dotnet.Ex.Log;

namespace DotnetWinFormApp
{
    public class RegionControl : Control
    {
        public RegionControl()
            : base()
        {
            this.Size = new System.Drawing.Size(200, 200);
        }


        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);

            System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();

            // Set a new rectangle to the same size as the button's 
            // ClientRectangle property.
            System.Drawing.Rectangle newRectangle = this.ClientRectangle;

            // Decrease the size of the rectangle.
            //newRectangle.Inflate(-10, -10);

            // Draw the button's border.
            e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle);

            // Increase the size of the rectangle to include the border.
            newRectangle.Inflate(1, 1);

            // Create a circle within the new rectangle.
            graphicsPath.AddEllipse(newRectangle);

            // Set the button's Region property to the newly created 
            // circle region.
            var region = new System.Drawing.Region(graphicsPath);
            region.Exclude(new System.Drawing.Rectangle(20, 20, 40, 40));
            this.Region = region;
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            Loger.Debug("OnMouseMove");
        }

        protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);
            Loger.Debug("OnMouseEnter");
        }

        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            Loger.Debug("OnMouseLeave");
        }

        protected override void OnMouseHover(EventArgs e)
        {
            base.OnMouseHover(e);
            Loger.Debug("OnMouseHover");
        }

        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnMouseClick(e);
            Loger.Debug("OnMouseClick");
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            Loger.Debug("OnMouseDown");
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            Loger.Debug("OnMouseUp");
        }

        protected override void OnMouseDoubleClick(MouseEventArgs e)
        {
            base.OnMouseDoubleClick(e);
            Loger.Debug("OnMouseDoubleClick");
        }

        protected override void OnMouseWheel(MouseEventArgs e)
        {
            base.OnMouseWheel(e);
            Loger.Debug("OnMouseWheel");
        }

        protected override void OnMouseCaptureChanged(EventArgs e)
        {
            base.OnMouseCaptureChanged(e);
            Loger.Debug("OnMouseCaptureChanged");
        }
    }
}
